﻿using System;
using System.Collections.Generic;

using BrightSword.SwissKnife;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests.BrightSword.SwissKnife
{
    [TestClass]
    public class CodeGenerationUtilitiesTests
    {
        [TestMethod]
        public void TestRenamePrimitiveTypeToConcreteType()
        {
            Assert.AreEqual("Int32",
                            typeof (Int32).RenameToConcreteType());
        }

        [TestMethod]
        public void TestRenameNonGenericDiscreteTypeToConcreteType()
        {
            Assert.AreEqual("Type",
                            typeof (Type).RenameToConcreteType());
        }

        [TestMethod]
        public void TestRenameNonGenericDiscreteTypeToConcreteTypeWithSuffix()
        {
            Assert.AreEqual("TypeDTO",
                            typeof (Type).RenameToConcreteType(suffix: "DTO"));
        }

        [TestMethod]
        public void TestRenameNonGenericDiscreteTypeToConcreteTypeWithPrefix()
        {
            Assert.AreEqual("WType",
                            typeof (Type).RenameToConcreteType("W"));
        }

        [TestMethod]
        public void TestRenameNonGenericInterfaceToConcreteType()
        {
            Assert.AreEqual("ConvertibleDTO",
                            typeof (IConvertible).RenameToConcreteType(suffix: "DTO"));
        }

        [TestMethod]
        public void TestRenameCollectionClassWithInterfaceToConcreteType()
        {
            Assert.AreEqual("ListDTO<ConvertibleDTO>",
                            typeof (List<IConvertible>).RenameToConcreteType(suffix: "DTO"));
        }

        [TestMethod]
        public void TestRenameCollectionInterfaceWithInterfaceToConcreteType()
        {
            Assert.AreEqual("List<Convertible>",
                            typeof (IList<IConvertible>).RenameToConcreteType());
        }

        [TestMethod]
        public void TestRenameMalformedGenericInterfaceToConcreteType()
        {
            Assert.AreEqual("MalformedGenericInterface<Int32>",
                            typeof (MalformedGenericInterface<int>).RenameToConcreteType());
        }

        [TestMethod]
        public void TestRenameMalformedInterfaceToConcreteType()
        {
            Assert.AreEqual("MalformedInterface",
                            typeof (MalformedInterface).RenameToConcreteType());
        }

// ReSharper disable InconsistentNaming

        private interface MalformedGenericInterface<T> {}

        private interface MalformedInterface {}

        // ReSharper restore InconsistentNaming
    }
}